<div class="layui-form" lay-filter="layuiadmin-form" id="layuiadmin-form">
    <div class="layui-form-item">
        <label class="layui-form-label">工号</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="number" value="{{ d.params.number || '' }}" lay-verify="required"
                       placeholder="请输入..." autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="name" value="{{ d.params.name || '' }}" lay-verify="required"
                       placeholder="请输入..." autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <div class="layui-input-inline">
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="user_avatarBtn">上传图片</button>
                <div class="layui-upload-list">
                    <script type="text/html" template>
                        {{# if(d.params.user_avatar){ }}
                        <img class="layui-upload-img" id="user_avatar" src="{{ d.params.user_avatar }}">
                        {{# }else{ }}
                        <img class="layui-upload-img" id="user_avatar">
                        {{# } }}
                    </script>
                </div>
            </div>
            <input type="hidden" name="user_avatar" v-model="find.image">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门</label>
        <div class="layui-input-inline append-group">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">已投票数</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="ticket_put" value="{{ d.params.ticket_put || '' }}" lay-verify="required"
                       placeholder="请输入..." autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">已获得票数</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="ticket" value="{{ d.params.ticket || '' }}" lay-verify="required"
                       placeholder="请输入..." autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="layuiadmin-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>
<style>
    .layui-upload-img{max-width:100px;max-height: 200px}
</style>
<script>
    layui.use(['admin', 'form', 'helper' , 'upload'], function () {
        var $        = layui.$
            , admin  = layui.admin
            , setter = layui.setter
            , layer  = layui.layer
            , helper = layui.helper
            , form   = layui.form;
        let id = 0;
        if (window.params){
            id = window.params['id'];
        }
        helper.requestRenderSelect('/app/vote-index/deparent?id=' + id , 'deparent_id' , '.append-group' , form);
        setTimeout(function(){
            $('.layui-upload-img').each((e, item) => {
                let id = $(item).attr('id')
                let renderId = '#' + id + 'Btn';
                helper.uploadRender(renderId , setter.requestUrl + '/upload' , function(res){
                    $(item).attr('src', res.data.path);
                    $('input[name=' + id + ']').val(res.data.url);
                });
            })
        } , 500)
    });
</script>